<include file="Layout/header" />
<body>
<div class="breadcrumbs" id="breadcrumbs"> 
  <script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>
  <ul class="breadcrumb">
    <li> <i class="icon-home home-icon"></i> <a href="{:U('Admin/Index/welcome')}">首页</a> </li>
    <li class="active">银行列表</li>
  </ul>
</div>
<div class="page-content">
  <div class="page-header">
    <h1> 系统管理 <small> <i class="icon-double-angle-right"></i> 银行列表 </small> </h1>
  </div>
  <div class="row">
    
    <div class="col-xs-12">
    <a class="btn btn-primary" href="{:U('Admin/Setting/bank_add')}" style="margin-bottom: 5px;"><i class="icon-plus align-top bigger-125"></i>新增银行</a>
      <div class="table-responsive">
        <table id="example-advanced" class="table table-striped table-bordered table-hover">
          <thead>
            <tr>
             <th class="center"> <label>
                  <input class="ace" type="checkbox">
                  <span class="lbl"></span> </label>
              </th>
              <th>排序</th>
              <th>名称</th>
              <th>logo</th>
              <th>状态</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
          <form method="post" action="{:U('Admin/Setting/bank_del_all')}" id="ondel">
           <foreach name="bank.data" item="val">
               <tr>
                <td class="center"><label>
                    <input class="ace" type="checkbox" value="{$val.id}" name="id[]">
                    <span class="lbl"></span> </label></td>
                <td>
                {$val.sort}
                </td> 
                <td class="hidden-480">
                {$val.name}</td>
                <td >
                <div class="col-sm-8">
				<a href="{$val.home}" target="_blank">	<img src="{$val.logo}" /></a>
				</div></td>
                <td class="td-status">
				<if condition="$val.isShow eq 0"><span class="label label-sm label-inverse arrowed-in">已关闭</span><else /><span class="label label-sm label-success">已开启</span></if>
				 </td> 
                <td><div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
                 <if condition="$val.isShow eq '1'"> <a class="btn btn-xs btn-inverse" onClick="bank_stop(this,{$val.id})" href="javascript:;"> <i class=" icon-ban-circle bigger-120"></i> </a>
                 <elseif condition="$val.isShow eq '0'" />
                      <a class="btn btn-xs btn-success" onClick="bank_start(this,{$val.id})" href="javascript:;"> <i class="icon-ok bigger-120"></i> </a> </if>
                
                <a class="btn btn-xs btn-info" href="{:U('Admin/Setting/bank_edit')}/id/{$val.id}"> <i class="icon-edit bigger-120"></i> </a> 
                <a class="btn btn-xs btn-danger" onClick="bank_del(this,{$val.id})"> <i class="icon-trash bigger-120"></i> </a> </div></td>
              </tr>
              
               
              </foreach>
          </form>
            </tbody>
          
        </table>
        <div>
          <button class="btn btn-danger" onClick="datadel()">批量删除</button>
        </div>
      </div>
      <input type="hidden" value="{:U('Admin/Setting/bank_show')}" id="bank_show">
       <input type="hidden" value="{:U('Admin/Setting/bank_del')}" id="del_cat">
      <!-- /.table-responsive --> 
    </div>
    <div >{$article.page}</div>
  </div>
</div>
<include file="Layout/js"/> 
 <link rel="stylesheet" href="__ADMIN_CSS__/jquery.treetable.css" />
 <script src="__ADMIN_JS__/jquery.treetable.js"></script>
 <script src="__ADMIN_JS__/jquery.dataTables.min.js"></script> 
 <script src="__ADMIN_JS__/jquery.dataTables.bootstrap.js"></script> 
 <script src="__ADMIN_JS__/bootbox.js"></script> 
 <script type="text/javascript">
			jQuery(function($) {
 				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
			
  				
			})
 		</script> 
<script type="text/javascript"> 
/*资讯-下架*/
function bank_stop(obj,id){
	var host=$("#bank_show").val();
	  bootbox.setLocale("zh_CN");  
      bootbox.confirm("确定关闭该银行?", function(result) {  
        if (result) {
		$.ajax({
			url:host,
			type:"POST",
			dataType:"json",
			data:{bank_id:id},
			success: function(s){
				if(s.status == '1'){
			$(obj).parents("tr").find(".btn-group").prepend('<a class="btn btn-xs btn-success" onClick="bank_start(this,'+id+')" href="javascript:;" title="开启"><i class="icon-ok bigger-120"></i> </a>');
		    $(obj).parents("tr").find(".td-status").html('<span class="label label-sm label-inverse arrowed-in">已关闭</span>');
		    $(obj).remove();
		    bootbox.alert('已关闭!');
			}else{
				 bootbox.alert(s.info);  
				  }
				}
			});
		
		
		}
	});
}

/*资讯-发布*/
function bank_start(obj,id){
	 var host=$("#bank_show").val();
	  bootbox.setLocale("zh_CN");  
      bootbox.confirm("确定开启该银行?", function(result) {  
        if (result) {  
		$.ajax({
			url:host,
			type:"POST",
			dataType:"json",
			data:{id:id},
			success: function(s){
			if(s.status == '1'){
			  $(obj).parents("tr").find(".btn-group").prepend('<a class="btn btn-xs btn-inverse" onClick="bank_stop(this,'+id+')" href="javascript:;"> <i class=" icon-ban-circle bigger-120"></i>');
		      $(obj).parents("tr").find(".td-status").html('<span class="label label-sm label-success">已开启</span>');
		      $(obj).remove();
		      bootbox.alert('已开启!');
				}else{
				 bootbox.alert(s.info);  
				  }
				}
		});
		
		
		}
	});
}      
      /* 删除*/
function bank_del(obj,id){
	   var host= $("#del_cat").val();
	  
      bootbox.setLocale("zh_CN");  
      bootbox.confirm("确定删除该记录?", function(result) {  
        if (result) {  
           $.ajax({
			 url:host,
			type:"POST",
			dataType:"json",
			data:{id:id},
			success: function(data){
 				if(data.status==0){
 				bootbox.alert(data.info);	
					}else{
				$(obj).parents("tr").remove();		
						}
				}
			})
		
		 
        }  
      });  
 
}
/*批量-删除*/
function datadel(){
	  var is_check=$("input[type='checkbox']").is(':checked');
    if(is_check){
	    bootbox.setLocale("zh_CN");  
      bootbox.confirm("确定删除该记录?", function(result) {  
        if (result) {  
           $("#ondel").submit();
         }  
      }); 
    }else{
      bootbox.alert({  
            buttons: {  
               ok: {  
                    label: '返回',  
                    className: 'btn-myStyle'  
                }  
            },  
            message: '请选择要删除的记录',  
            callback: function() {  
               // alert('关闭了alert');  
            },  
            title: "提示信息",  
        });
    } 
	 
	
}
 </script>
</body>
</html>